package com.yin.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

import javax.sql.DataSource;


/**
 * 事务配置类
 * 
 * @author Yin
 */
@Configuration
public class TransactionConfig implements TransactionManagementConfigurer {
	// ~ Instance fields
	// ================================================================================================
	@Autowired
	private DataSource dataSource;

	// ~ Methods
	// ========================================================================================================
	@Bean(name = "transactionManager")
	@Override
	public PlatformTransactionManager annotationDrivenTransactionManager() {
		return new DataSourceTransactionManager(dataSource);
	}
}
